home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DELPHI / CODEAPP.ZIP / FILEFUNC.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-12-16  |  1.3 KB  |  55 lines

  1. unit Filefunc;
  2.  
  3. { File functions}
  4.  
  5. interface
  6.  
  7. uses WinTypes, WinProcs, SysUtils;
  8.  
  9.   const
  10.   DateTimeFormat = 'mmm d, yy  hh:mm:ss';
  11.  
  12.   function GetFileInfo(const FN: string; var F: TSearchRec): boolean;
  13.  
  14.   function ShowFileStats(const F: TSearchRec): string;
  15.  
  16. implementation
  17.  
  18. function GetFileInfo(const FN: string; var F: TSearchRec): boolean;
  19. {-Returns True if file is found}
  20. begin
  21.   Result := FindFirst(FN, faAnyFile, F) = 0;
  22.   FindClose(F);
  23.   if not Result then
  24.     MessageBeep(MB_ICONASTERISK);
  25. end;
  26.  
  27. function ShowFileStats(const F: TSearchRec): string;
  28. {-Return formatted string w/ file info}
  29. var
  30.   AttrStr, S: string;
  31. begin
  32.   try
  33.     S := FormatDateTime(DateTimeFormat, FileDateToDateTime(F.Time));
  34.   except {illegal date or time}
  35.     S := 'BAD FILE DATE';
  36.   end;
  37.  { Formatting for attribute string }
  38.   with F do
  39.   begin
  40.     AttrStr := '----';
  41.     if Attr and faReadOnly <> 0 then
  42.       attrstr[1] := 'R';
  43.     if Attr and faArchive <> 0 then
  44.       attrstr[2] := 'A';
  45.     if Attr and faSysFile <> 0 then
  46.       attrstr[3] := 'S';
  47.     if Attr and faHidden <> 0 then
  48.       attrstr[4] := 'H';
  49.   end;
  50.   Result := Format('%12s  Size: %6s  Date: %s  %s',
  51.     [F.Name, FormatFloat(',##########0', F.Size), S, AttrStr]);
  52. end;
  53.  
  54. end.
  55.